<html>
<head>
<title>支付宝支付</title>
<script type="text/javascript" src="../vue/vue.min.js"></script>
<script type="text/javascript" src="../vue/vue-resource.min.js" ></script>
<script src="../qirous/qrious.min.js"></script>
<script type="text/javascript" src="../js/textColor.js"></script>
</head>
<body style="text-align: center;margin: auto 0;">
	
	<div id="app" style="text-align: center;">
		
		<div style="text-align: center;width: 100%;">
			<h1 >{{text}}</h1>
		</div>
		
		<div >
			金额：<input type="text" placeholder="请输入金额" v-model="amount" />
			<input type="button" value="支付" @click="pay()" />
			<input type="button" value="取消" onclick="location.reload()" /><br><br>
		</div>
		
		<div id="pay"></div>
		
	</div>

</body>
<script>
	
	new Vue({
		el:"#app",
		data:{
			text:" 欢 迎 使 用 支 付 宝 支 付 小 程 序     <-,-->",
			timer:null,
			amount:""
		},
		methods:{
			pay(){
				if(parseInt(this.amount) > 0 && parseInt(this.amount.substring(0,1)) > 0) {
					this.$http.get("http://localhost:9999/pay/createOrder?amount="+this.amount).then(function(obj){
						console.log(obj.bodyText);
						document.getElementById("pay").innerHTML = obj.bodyText;
						document.forms[0].submit();
					})
				}else{
					alert("请输入合法的金额");
					location.reload();
				}
			}
			
		},
		created() {
			if(this.timer != null){
			    return;
			}
			this.timer = setInterval(()=>{
			       let start = this.text.substring(0,1);//截取下标为0的字符串
			       let end = this.text.substring(1);//截取从下标为1到结束的字符串
			       this.text = end + start;
			},350);
		}
	});

	

	
</script>
</html>